﻿Imports FairShop
Imports FairShop.Objects
Imports FairShop.Presenters
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions

<TestClass()> _
Public Class TestProgress

    Private testContextInstance As TestContext

    '''<summary>
    '''Gets or sets the test context which provides
    '''information about and functionality for the current test run.
    '''</summary>
    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(ByVal value As TestContext)
            testContextInstance = value
        End Set
    End Property

#Region "Additional test attributes"
    '
    ' You can use the following additional attributes as you write your tests:
    '
    ' Use ClassInitialize to run code before running the first test in the class
    '<ClassInitialize()> _
    'Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
    'End Sub
    '
    ' Use ClassCleanup to run code after all tests in a class have run
    ' <ClassCleanup()> Public Shared Sub MyClassCleanup()
    ' End Sub
    '
    ' Use TestInitialize to run code before running each test
    ' <TestInitialize()> Public Sub MyTestInitialize()
    ' End Sub
    '
    ' Use TestCleanup to run code after each test has run
    '<TestCleanup()> _
    'Public Sub MyTestCleanup()
    'End Sub

#End Region

    <TestMethod()> _
    Public Sub TestProgress1()
        ' ARRANGE
        Dim p As New ProgressParts(100, 100)
        p.Start(0, 100)

        ' ACT
        p.Increase(0)

        ' ASSERT
        Assert.AreEqual(5, p.GetProgressValueOp1000(), "Verkeerde waarde voor progress")
    End Sub

    <TestMethod()> _
    Public Sub TestProgress2()
        ' ARRANGE
        Dim p As New ProgressParts(100, 100)
        p.Start(0, 100)
        p.Finish(0)
        p.Start(1, 100)

        ' ACT
        p.Increase(1)

        ' ASSERT
        Assert.AreEqual(505, p.GetProgressValueOp1000(), "Verkeerde waarde voor progress")
    End Sub

    <TestMethod()> _
    Public Sub TestProgress3()
        ' ARRANGE
        Dim p As New ProgressParts(100, 300)
        p.Start(0, 100)
        p.Finish(0)
        p.Start(1, 100)

        ' ACT
        p.Increase(1)

        ' ASSERT
        Assert.AreEqual(258, p.GetProgressValueOp1000(), "Verkeerde waarde voor progress")
    End Sub

    <TestMethod()> _
    Public Sub TestProgress4()
        ' ARRANGE
        Dim p As New ProgressParts(100, 100, 100)
        p.Start(0, 100)
        p.Finish(0)
        p.SetGewicht(1, 0)
        p.Start(2, 100)

        ' ACT
        p.Increase(2)

        ' ASSERT
        Assert.AreEqual(505, p.GetProgressValueOp1000(), "Verkeerde waarde voor progress")
    End Sub

    <TestMethod()> _
    Public Sub TestTimeRemaining1()
        ' ARRANGE
        Dim p As New ProgressParts(100, 100)
        p.Start(0, 100, 0)
        p.Increase(0)

        ' ACT
        Dim result As TimeSpan = p.GetTimeRemaining(10000)

        ' ASSERT
        Assert.AreEqual(1990000L, result.Ticks, "Verkeerde waarde voor ticks")
    End Sub

    <TestMethod()> _
    Public Sub TestTimeRemaining2()
        ' ARRANGE
        Dim p As New ProgressParts(100, 100)
        p.Start(0, 100, 0)
        p.SetDoneValue(0, 50)

        ' ACT
        Dim result As TimeSpan = p.GetTimeRemaining(10000)

        ' ASSERT
        Assert.AreEqual(30000L, result.Ticks, "Verkeerde waarde voor ticks")
    End Sub

    <TestMethod()> _
    Public Sub TestTimeRemaining3()
        ' ARRANGE
        Dim p As New ProgressParts(100, 300)
        p.Start(0, 100, 0)
        p.Finish(0)
        p.Start(1, 100, 10000)
        p.SetDoneValue(1, 50)

        ' ACT
        Dim result As TimeSpan = p.GetTimeRemaining(20000)

        ' ASSERT
        Assert.AreEqual(20000L, result.Ticks, "Verkeerde waarde voor ticks")
    End Sub

End Class
